package cn.hl.feign;

import cn.hl.domain.MovieTicket;
import cn.hl.dto.MovieTicketDto;
import cn.hl.query.MovieTicketQuery;
import cn.hl.result.JSONResult;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@FeignClient(value = "movie-server",fallbackFactory = MovieServerFallbackFactory.class)
@RequestMapping("/movieTicket")
public interface MovieServer {

    /**
     * 保存和修改公用的
     */
    @RequestMapping(value="/save",method= RequestMethod.POST)
    JSONResult saveOrUpdate(@RequestBody MovieTicket movieTicket);

    /**
     * 删除对象
     */
    @RequestMapping(value="/{id}",method=RequestMethod.DELETE)
    JSONResult delete(@PathVariable("id") Long id);

    /**
     * 获取对象
     */
    @RequestMapping(value = "/{id}",method = RequestMethod.GET)
    JSONResult get(@PathVariable("id")Long id);


    /**
     * 查询所有对象
     */
    @RequestMapping(value = "/list",method = RequestMethod.GET)
    JSONResult list();


    /**
     * 带条件分页查询数据
     */
    @RequestMapping(value = "/pagelist",method = RequestMethod.POST)
    JSONResult page(@RequestBody MovieTicketQuery query);

    @RequestMapping(value="/buyMovieTicketById",method= RequestMethod.POST)
    JSONResult buyMovieTicketById(@RequestBody MovieTicketDto movieTicketDto);

    /**
     * 根据Id查询用户的电影票信息
     */
    @RequestMapping(value="/findMovieTicketByUserId/{id}",method= RequestMethod.POST)
    JSONResult findMovieTicketByUserId(@PathVariable("id")Long id);

    /**
     * 根据电影Id观看电影
     */
    @RequestMapping(value="/watchMovieById",method= RequestMethod.POST)
    JSONResult watchMovieById(@RequestBody MovieTicketDto movieTicketDto);

    /**
     * 随机赠送电影票
     */
    @RequestMapping(value="/sendMovieTicket/{id}",method= RequestMethod.POST)
    JSONResult sendMovieTicket(@PathVariable("id")Long id);
}
